<template>
	<view class="p30">
		<cust-empty desc="暂无数据" v-if="loadStatus=='none'">
		</cust-empty>
		<time-record :list="list">
			<template v-slot="{ data }">
				<view class="card-grey-box">
					<view class="bold">{{data.carName}}</view>
					<view class="mt30 flex-between">
						<text class="c-desc">{{data.logAssortName}}</text>
						<text class="c-desc">{{data.logTypeName}}</text>
						<text class="c-desc">{{data.content}}</text>
					</view>
				</view>
			</template>
		</time-record>
		<view class="nomore" v-if="loadStatus != 'none'">
			<u-loadmore :status="loadStatus" />
		</view>
	</view>
</template>

<script>
	import timeRecord from "@/components/simple/time-record.vue";
	import {
		getOperateLogAPI,
		getDicDataAPI
	} from "@/api/api/my.js"
	import custEmpty from "@/components/cust-empty/index.vue";
	import pages from "@/mixins/pages.js"
	let dicData1 = [];
	let dicData2 = [];
	export default {
		components: {
			timeRecord,
			custEmpty
		},
		mixins: [pages],
		methods: {
			dictValueBykey(
				data,
				targetValue,
				key = "dictKey",
				value = "dictValue",
				isReturnValue = true
			) {
				let target = null;
				for (let i = 0; i < data.length; i++) {
					let item = data[i];
					if ((item[key] == targetValue)) {
						if (isReturnValue) {
							target = item[value];
						} else {
							target = item;
						}
						break;
					}
				}
				return target;

			}
		},
		onLoad() {
			this.type = "object";
			this.showPropListCallcack = (obj, item) => {
				return {
					...obj,
					id: item.id,
					carName: item.carName,
					logAssort: item.logAssort,
					logType: item.logType,
					content: item.content
				}
			};
			this.funAPI = getOperateLogAPI;
			this.initList();
			this.callback = (item) => {
				return {
					logAssortName: this.dictValueBykey(dicData1, item.logAssort),
					logTypeName: this.dictValueBykey(dicData2, item.logType)
				}
			}
			getDicDataAPI("customerOperateLogAssort").then(([err, data]) => {
				if (err) return;
				dicData1 = data;
				getDicDataAPI("customerOperateLog").then(([err, data2]) => {
					if (err) return;
					dicData2 = data2;
					this.getListFun();
				});
			});

		},
	}
</script>

<style>
</style>
